#include<iostream>
#include<unordered_map>

using namespace std;
typedef long long ll;
const int N = 1e6 + 10;
ll a[N];
unordered_map<ll,int>q;

int main()
{
	int t, n; cin >> t >> n;
	while (t--)
	{
		for (int i = 1; i <= n; i++)
		{
			cin >> a[i];
		}
		int le = 1; int ri = 1;int ret = 0;
		while (ri <= n)
		{
			q[a[ri]]++;
			while (q[a[ri]] > 1)
			{
				q[a[le]]--;
				le++;
			}
			ret = max(ret, ri - le + 1);
			ri++;
		}
		cout << ret;
	}
	return 0;
}
